import type { ImageVO, ImageSearchParams } from '@/api/Image.ts'
import type { PageResult } from '@/api/Common.ts'
import httpClient, { ContentType } from '@/api/client.ts'

export const ImageApi = {
  searchPublic: async (param: ImageSearchParams): Promise<PageResult<ImageVO>> => {
    const { data } = await httpClient.post<PageResult<ImageVO>>(`/images/search`, param)
    return data
  },
  search: async (param: ImageSearchParams): Promise<PageResult<ImageVO>> => {
    const { data } = await httpClient.post<PageResult<ImageVO>>(`/admin/images/search`, param)
    return data
  },
  upload: async (type: string, file: File): Promise<number> => {
    const { data } = await httpClient.post<number>(
      `/admin/images/upload`,
      { type, uploadFile: file },
      { headers: { 'Content-Type': ContentType.FORM_DATA } }
    )
    return data
  },
  enable: async (id: string): Promise<boolean> => {
    const { data } = await httpClient.post(`/admin/images/enable`, null, { params: { id } })
    return data
  },
  disable: async (id: string): Promise<boolean> => {
    const { data } = await httpClient.post(`/admin/images/disable`, null, { params: { id } })
    return data
  },
  delete: async (id: string): Promise<boolean> => {
    const { data } = await httpClient.post(`/admin/images/delete`, null, { params: { id } })
    return data
  },
}


